// ==UserScript==
// @name         电力看板
// @namespace    none
// @version      0.8
// @description  CSS修改脚本
// @author       Rainbow
// @match        *://192.168.200.12/iomm/*
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';
    // http://10.117.16.218/iomm/login?redirectUrl=%2Fiomm%2Fdashboard%2Frunninginterfaces%2Findex
    //http://10.117.16.218/iomm/dashboard/runninginterfaces/index
    console.log('Rainbow script Of electric')
    let username = 'iomm'
    let pwd = '63189188'
    //填写用户名
    // let usernameInput = document.querySelector(pathOfusernameInput)
    // usernameInput.value = username
    // //填写密码
    // let pwdInput = document.querySelector(pathOfpwdInput)
    // pwdInput.value = pwd
    //点击登陆
    //document.querySelector(pathOfBtn).click()
    setTimeout(() => {
        removeScroll()
        simLogin()
    }, 4*1000);
    
    function simLogin()
    {
        let usernameNode = document.getElementById('username-inputEl')
        let passwordNode = document.getElementById('password-inputEl')
        let btn = document.getElementById('button-1020-btnInnerEl')
        if(usernameNode != null && passwordNode != null && btn != null)
        {
            usernameNode.value = username;
            passwordNode.value = pwd;
            btn.click()
        }
    }

    function removeScroll()
    {
        let elem = document.querySelector('#ups')
        resetCss(elem,'hidden','overflow')
    }

    function resetCss(elem,param,styleAttr)
    {
        try {
            if(undefined != elem && null != elem)
            {
                elem.style[styleAttr] = param;
            }
        } catch (error) {
            //do nothing
        }
    }
})();